package com.zhuss.product.train;

import com.zhuss.bean.bo.product.train.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.zhuss.common.OperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.DzcxException;

/**
 * @description: 车次操作的Service
 * @author: zhushanshuo
 * @create: Mon Jan 04 08:55:12 CST 2021
 **/
@Component("trainOperateService")
public class TrainOperateService implements OperateService<Void, Object> {

	@Autowired
	@Qualifier("trainCreate")
	private Processor<Object, CreateTrainBo> trainCreate;

	@Autowired
	@Qualifier("trainUpdate")
	private Processor<Object, UpdateTrainBo> trainUpdate;

	@Autowired
	@Qualifier("trainDelete")
	private Processor<Object, DeleteTrainBo> trainDelete;

	@Autowired
	@Qualifier("trainStart")
	private Processor<Object, StartTrainBo> trainStart;

	@Autowired
	@Qualifier("trainStop")
	private Processor<Object, StopTrainBo> trainStop;

	@Autowired
	@Qualifier("trainSell")
	private Processor<Object, SellTrainBo> trainSell;

	/**
	 * 创建
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
	public Void create(Object param) throws DzcxException {

		CreateTrainBo bo = (CreateTrainBo) param;

		trainCreate.process(bo);

		return null;
	}

	/**
	 * 修改
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
    public Void update(Object param) throws DzcxException {

		UpdateTrainBo bo = (UpdateTrainBo) param;

		trainUpdate.process(bo);

    	return null;
    }

	/**
	 * 删除
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public Void delete(Object param) throws DzcxException {

		DeleteTrainBo bo = (DeleteTrainBo) param;

		trainDelete.process(bo);

		return null;
	}

	/**
	 * 启用
	 */
	@Transactional(rollbackFor = Exception.class)
	protected Void start(Object param) throws DzcxException {

		StartTrainBo bo = (StartTrainBo) param;

		trainStart.process(bo);

		return null;
	}

	/**
	 * 停用
	 */
	@Transactional(rollbackFor = Exception.class)
	protected Void stop(Object param) throws DzcxException {

		StopTrainBo bo = (StopTrainBo) param;

		trainStop.process(bo);

		return null;
	}

	/**
	 * 停用
	 */
	@Transactional(rollbackFor = Exception.class)
	protected Void sell(Object param) throws DzcxException {

		SellTrainBo bo = (SellTrainBo) param;

		trainSell.process(bo);

		return null;
	}



}

